<?php
include("admin_check.php");
include_once("../class/member_class.php");
include_once("action.php");
session_start();
header("Content-Type: text/html;charset=utf-8");
checkqx(1,3);
if ($_POST['Search']){
    $SearchContent=$_POST['SearchContent'];
    if ($SearchContent!=NULL){
        $SearchType=$_POST['SearchType'];
        if ($SearchType==1){
            #搜索会员编号
            $_SESSION['Search']="and nickname='".$SearchContent."'";
        }elseif($SearchType==2){
            #搜索姓名
            $_SESSION['Search']="and username='".$SearchContent."'";
        }elseif($SearchType==3){
            #手机
            $_SESSION['Search']="and usertel='".$SearchContent."'";
        }elseif($SearchType==4){
            #身份证
            $_SESSION['Search']="and usercard='".$SearchContent."'";
        }
    }else{
        $_SESSION['Search']=NULL;
    }
}else{
    if ($_GET['page']==NULL){
        $_SESSION['Search']=NULL;
        $_SESSION['SearchTime']=NULL;
    }
}

if($_POST['button']){
    if($_POST['id']){
        $_member=new member_class();
        $us=$_member->getMemberbyID($_POST['id']);
        $member['chr2']=2;
        edit_update_cl('member',$member,$us['id']);
        alert('发放成功.','?');
    }else{
        alert('设置出错,确认失败.','?');
    }
}



?>
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/table.css" rel="stylesheet" type="text/css">
<link href="css/style.css" rel="stylesheet" type="text/css">
<link href="../layui-master/dist/css/layui.css" rel="stylesheet" type="text/css">
<script src="../layui-master/dist/layui.js"></script>
<title>福 利 会 员</title>
</head>
<body>

<table width="100%" cellpadding="3" cellspacing="1" border="0" align="center" class="layui-table" lay-skin="line">
    <form name="form1" method="post" action="?">
        <tr>
            <td height="10" colspan="12" align="left">
                <select name="SearchType" id="SearchType">
                    <option value="1">会员编号</option>
                    <option value="2">会员姓名</option>
                    <option value="3">会员手机</option>
                    <option value="4">身份证</option>
                </select>
                <input type="text" name="SearchContent" id="SearchContent">
                <input type="submit" name="Search" id="Search" class="layui-btn layui-btn-small" value="搜索"></td>
        </tr>
    </form>
    <tr>
        <td height="10" colspan="12" align="center">福 利 会 员</td>
    </tr>
    <tr>
        <td align="center">会员编号</td>
        <td align="center">会员姓名</td>
        <td align="center">联系电话</td>
        <td align="center">身份证号码</td>
        <td align="center">级别</td>
        <td align="center">小区业绩</td>
        <td align="center">操作</td>
    </tr>
    <?php
    $pagesize = 20; //设置每页记录数
    $sql = "SELECT * FROM `member` WHERE ulevel2>0  ".$_SESSION['Search']." ".$_SESSION['SearchTime']."";
    if($query = mysql_query($sql)){
        $sum = mysql_num_rows($query); //计算总记录数
    }else{
        $sum=0;
    }
    if($sum % $pagesize == 0) //计算总页数
        $total = (int)($sum/$pagesize);
    else
        $total = (int)($sum/$pagesize) + 1;
    if (isset($_GET['page'])) //获得页码
    {
        $p = (int)$_GET['page'];
    }
    else
    {
        $p = 1;
    }
    if ($p>$total){
        $p=$total;
    }
    $start = $pagesize * ($p - 1); //计算起始记录
    $sql = "SELECT * FROM `member` WHERE ulevel2>0  ".$_SESSION['Search']." ".$_SESSION['SearchTime']." order by id desc limit ".$start.",".$pagesize;
    if($query = mysql_query($sql)){
        while ($row=mysql_fetch_array($query)){
            ?>
            <form name="form1" method="post" action="?">
                <?php
                if ($row['chr2']=="0"){
                    $_color="#FF0000";
                }else{
                    $_color="";
                }
                ?>
                <tr>
                    <td style="background:<?=$_color?>" align="center"><input name="id" type="hidden" value="<?=$row['id']?>"><?=$row['nickname']?></td>
                    <td align="center"><?=$row['username']?></td>
                    <td align="center"><?=$row['usertel']?></td>
                    <td align="center"><?=$row['usercard']?></td>
                    <td align="center"><?=$row['ulevel2']?></td>
                    <td align="center"><?php echo $xarea=$row['area1']>$row['area2']?$row['area2']:$row['area1'];?></td>
                    <td align="center">
                        <input name="button" type="submit" class="layui-btn layui-btn-radius layui-btn-warm" id="button" value="发放">&nbsp;&nbsp;
                    </td>
                </tr>
            </form>
            <?php
        }
    }
    ?>
    <tr>
        <td colspan="12" align="right"><?php echo fenye($p,$pagesize,$sum,$total,$cx)?></td>
    </tr>
</table>
</body>
</html>